/**
 * 
 */
package com.HibernateRecepies.DAO;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.Hib.Util.SessionManager;
import com.HibernateRecepies.Domain.Address;
import com.HibernateRecepies.Domain.Contact_1;
import com.HibernateRecepies.Domain.Order_1;
import com.HibernateRecepies.Domain.Phone_Nest;

/**
 * @author Ignatiues charles arun
 * 
 *         Dec 7, 2010
 */
public class OrderDao3_3
	{

		private static SessionFactory sessionFactory;

		/**
		 * @param args
		 */
		public static void main(String[] args)
			{
				// TODO Auto-generated method stub

				sessionFactory = SessionManager.getSessionfactory();
				Session sess = sessionFactory.getCurrentSession();
				Transaction tx = sess.beginTransaction();

				Address objAdr = new Address();
				objAdr.setAddress1("Beach Resort");
				objAdr.setAddress2("Hawai");
				objAdr.setCity("Hawai");
				// objAdr.setId(new Long(102));
				objAdr.setState("Arizona");
				objAdr.setZipcode(20);

				Phone_Nest objPh = new Phone_Nest();
				objPh.setAreaCode("hw-xx-12");
				objPh.setTelNo("12-1232");

				Contact_1 objCnt = new Contact_1();
				objCnt.setAddress(objAdr);
				objCnt.setPhone(objPh);
				objCnt.setRecepient("Arun");

				Order_1 objOrdr = new Order_1();
				objOrdr.setHoliday_contact(objCnt);
				// objOrdr.setId(new Long(12));
				objOrdr.setWeekday_contact(objCnt);

				sess.save(objAdr);
				// sess.save(objOrdr);
				sess.saveOrUpdate(objOrdr);
				tx.commit();

			}
	}
